package com.corning.patient.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.corning.patient.entity.DiseasesEntity;
import com.corning.patient.service.DiseasesService;
import com.corning.common.utils.PageUtils;
import com.corning.common.utils.R;



/**
 * 
 *
 * @author wtt
 * @email 1239115389@qq.com
 * @date 2022-03-20 15:16:34
 */
@RestController
@RequestMapping("patient/diseases")
public class DiseasesController {
    @Autowired
    private DiseasesService diseasesService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = diseasesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{disId}")

    public R info(@PathVariable("disId") Integer disId){
		DiseasesEntity diseases = diseasesService.getById(disId);

        return R.ok().put("diseases", diseases);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody DiseasesEntity diseases){
		diseasesService.save(diseases);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DiseasesEntity diseases){
		diseasesService.updateById(diseases);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public R delete(@RequestBody Integer[] disIds){
		diseasesService.removeByIds(Arrays.asList(disIds));

        return R.ok();
    }

}
